package com.uottawa.librarytest.dao;

import static org.junit.Assert.*;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import com.uottawa.library.dao.BaseDAO;
import com.uottawa.library.dao.TitleDAO;
import com.uottawa.library.domain.Title;

public class TitleDAOTest {
	
	private TitleDAO titleDao;
	
	@Before
	public void setUp() {
	titleDao = new TitleDAO();
	}
	
	@After 
	public void cleanup() {
		new BaseDAO().cleanUp();
	}
	
	@Test
	public void testAddNewTitle() {
		Title title = new Title(222222);
		boolean added = titleDao.addTitle(title);
		assertTrue(added);
	}
	
	@Test
	public void testAddDuplicateTitle() {
		Title title = new Title(222222);
		boolean added = titleDao.addTitle(title);
		assertTrue(added);
		
		added = titleDao.addTitle(title);
		assertFalse(added);
		
	}

}
